#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
const int maxn = 30000 + 10;
int g[maxn], n, m, d[maxn], to[maxn], cnt, first[maxn], p1, p[maxn],Nex[maxn];
int w[maxn], dis[maxn];
queue<int>q;
void add(int u, int v, int l) {
    ++cnt;
    to[cnt] = v;
    Nex[cnt] = first[u];
    first[u] = cnt;
    w[cnt] = l;
}
int Min(int x, int y)
{
    if (x > y)
    {
        return y;
    }
    return x;
}
int main() {
    cin >> p1 >> n >> m;
    for (int i = 1; i <= p1; i++)
        scanf("%d", &g[i]);
    for (int i = 1; i <= m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        add(x, y, z);
        add(y, x, z);
    }
    int minn = 100000000;
    for (int k = 1; k <= n; k++) {
        memset(p, 0, sizeof(p));
        for (int i = 1; i <= n; i++)
            d[i] = 10000;
        d[k] = 0;
        q.push(k);
        p[k] = 1;
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            p[u] = 0;
            for (int i = first[u]; i; i = Nex[i]) {
                int v = to[i];
                if (d[v] > d[u] + w[i]) {
                    d[v] = d[u] + w[i];
                    if (!p[v]) {
                        q.push(v);
                        p[v] = 1;
                    }
                }
            }
        }
        int ans = 0;
        for (int j = 1; j <= p1; j++)
            ans += d[g[j]];
        minn = Min(minn, ans);
        
    }
    cout << minn << endl;
    return 0;
}